//
//  BaseViewController.m
//  jiaKaoXinBan
//
//  Created by Lidawei on 2020/11/10.
//  Copyright © 2020 Linyi Ningke Network Technology Co., Ltd. All rights reserved.
//

#import "BaseViewController.h"
#import "AppDelegate.h"
@interface BaseViewController ()

@end

@implementation BaseViewController

- (CGFloat)cellContentViewWith
{
    CGFloat width = [UIScreen mainScreen].bounds.size.width;
    
    // 适配ios7横屏
    if ([UIApplication sharedApplication].statusBarOrientation != UIInterfaceOrientationPortrait && [[UIDevice currentDevice].systemVersion floatValue] < 8) {
        width = [UIScreen mainScreen].bounds.size.height;
    }
    return width;
}



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
  
    self.navigationController.navigationBar.hidden = YES;
    self.automaticallyAdjustsScrollViewInsets = NO;
    

    [self setupNavBar];


    // 设置自定义导航栏背景图片
    self.customNavBar.barBackgroundImage = [UIImage imageNamed:@"导航栏"];


    [self wr_setStatusBarStyle:UIStatusBarStyleLightContent];
    
    
    
    
}


- (void)setNavTitleString:(NSString *)navTitleString{
    _navTitleString = navTitleString;
    self.customNavBar.title = navTitleString;
}


- (void)setupNavBar{
    
    [self.view addSubview:self.customNavBar];
    
    
//    [self.view insertSubview:self.customNavBar atIndex:0];
    
    [self.customNavBar wr_setBottomLineHidden:YES];
    if (self.navigationController.childViewControllers.count != 1) {
        [self.customNavBar wr_setLeftButtonWithImage:[UIImage imageNamed:@"返回"]];
    }
}



- (WRCustomNavigationBar *)customNavBar{
    if (_customNavBar == nil) {
        _customNavBar = [WRCustomNavigationBar CustomNavigationBar];
        _customNavBar.tintColor = [UIColor whiteColor];
        _customNavBar.titleLabelColor = rgba(24, 27, 37, 1);
        _customNavBar.barBackgroundImage = LocalImagePath(@"");
        _customNavBar.titleLabelFont = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
        _customNavBar.title = @"";
    }
    return _customNavBar;
}



- (void)pushViewController:(UIViewController *)controller {
    controller.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:controller animated:YES];
}


- (BOOL)isHaveLogin {
    if ([ZZPUtils readUserDefultsDataForKey:@"userInfo"] == nil) {
//        StudentStatusAddView *view = [StudentStatusAddView view];
//        view.reminLabel.text = @"提示";
//        view.contentLabel.text = @"登录之后才能有更好的体验，请马上登录吧！";
//        [view.rightButton setTitle:@"马上登录" forState:UIControlStateNormal];
//        view.addBlackClick = ^(NSInteger index) {
//            [self dismissViewControllerAnimated:YES completion:nil];
//            if(index == 102){
//                LoginViewController *login = [[LoginViewController alloc] init];
        
        
        LoginViewController *login = [[LoginViewController alloc] init];
        
        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:login];
//                nav.modalPresentationStyle = UIModalPresentationFullScreen;
//                [self presentViewController:nav animated: YES completion:nil];
        
        AppDelegate *del = [AppDelegate shareInstance];
        del.window.rootViewController = nav;
        
        
        
        
//            }
//        };
//        [ZZPUtils showAlertViewWithView:view andController:self];
        return NO;
    }
    return YES;
}
- (BOOL)isVip{
    if (userIsLogin) {
        if([GetHandleString(USERINFO, @"vipState") isEqualToString:@"0"]){
            //            不是会员
            return NO;
        }else{
            //            是会员
            
            NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init] ;
            [dateFormatter setDateFormat:@"yyyy-MM-dd"] ;
            NSDate *date = [dateFormatter dateFromString:GetHandleString(USERINFO, @"vipState")] ;
            NSTimeInterval interval  = [date timeIntervalSince1970] ;
            NSLog(@"interval=%f",interval) ;
            
            NSTimeInterval time = [[NSDate date] timeIntervalSince1970];
            
            if (interval < time) {
                return NO;
            }else{
                return YES;
            }
        }
    }
    return NO;
}


- (void)popViewControllerAnimated {
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)userLoginWithUserInfo:(NSDictionary *)user andFrom:(BOOL)isFaWuBu{
    
    

}






/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
